<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('列表')" />
</head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<input type="hidden" id="channelId" name="channelId" th:value="${mpChannel.id}">
					<div class="select-list">
						<ul>
							<li>
								银行类型：<select  id="bankId" name="bankId">
								<option value="" selected>----请选择----</option>
							</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="addWithdrawalBank()">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "channel/channelWithdrawalBank";
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                queryParams: queryParams,
                modalName: "渠道代付银行",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '标识',
					visible: false
				},
				{
					field : 'channelId', 
					title : '渠道标识',
					sortable: true,
                    visible: false
				},
                {
                    field : 'channelName',
                    title : '渠道名称'
                },
                {
                    field : 'channelCode',
                    title : '渠道编码'
                },
				{
					field : 'bankId', 
					title : '银行标识',
					sortable: true,
                    visible: false
				},
                {
                    field : 'bankName',
                    title : '银行类型'
                },
                {
                    field : 'bankCode',
                    title : '银行编码'
                },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

        // 渠道id
        function queryParams(params) {
            var search = $.table.queryParams(params);
            search.channelId = $("#channelId").val();
            return search;
        }

        /*银行类型下拉框*/
        $.post(ctx + "basedata/bank/list", {'name':''},function (response) {
            var data = response.rows;
            var option = "<option value=''>" + "全部" + "</option>";
            for (var i = 0; i < data.length; i++) {
                option += "<option value='"+ data[i].id +"'>" + data[i].name + "</option>"
            }
            $("#formId").find("select[name='bankId']").html("").append(option);
        });


        // 添加代付银行
        function addWithdrawalBank() {
            var url = prefix + '/add/' + $("#channelId").val();
            $.modal.open("添加支付方法", url);
        }

    </script>
</body>
</html>